import {
  createRouter,
  createWebHashHistory
} from 'vue-router'

const routes = [{
    path: '/',
    name: 'Home',
    component: () => import('../views/home/Home.vue'),
    children: [{
        path: '/',
        name: 'homeIndex',
        component: () => import('../views/home/homeIndex.vue'),
      },
      {
        path: '/category',
        name: '/category',
        component: () => import('../views/category/index.vue'),
      },
      {
        path: '/category/sub',
        name: '/category/sub',
        component: () => import('../views/category/sub.vue'),
      },
      {
        path: '/goods/index',
        name: '/goods/index',
        component: () => import('../views/goods/index.vue'),
      }
    ]
  },

]

const router = createRouter({
  history: createWebHashHistory(), // 我们用的hash
  routes,
  // 每次切路由跳转的时候， 滚动到页面最顶部
  scrollBehavior() {
    // vue 2 用的是 y x
    //  vue3 top left
    return {
      left: 0,
      top: 0
    }
  }
})

export default router